#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>


int main(void)
{
	int userbuf;
	
	int fd = open("/dev/light_drv",O_RDWR);
	if(fd == -1)
	{
		printf("open error\n");
		return fd;
	}
	
	
	//读数据
	while(1)
	{
		read(fd, &userbuf,sizeof(userbuf));
		if(userbuf == 1)
		{
			printf("light = %d\n", userbuf);
		}
		
		usleep(100 * 1000);
		
	}
	
	close(fd);
	
	return 0;
}